import flet as ft

class Header(ft.Page):
    def __init__(self, page):
        super().__init__()
        self.page = page
        self.search_value = "夜空中最亮的星"
       
        def build(self):
            BG = "#041955"
            FG = "#3450a1"
            def update_search_value(value):
                self.search_value = value
                print(value,self.search_value)
            def handle_search(e):
                print(self.search_value)
            return ft.Container(
                content=ft.Row([
                    ft.IconButton(icon=ft.Icons.PERSON,icon_color=ft.Colors.WHITE),
                    ft.Container(
                        content=ft.TextField(
                            value=self.search_value,
                            label_style=ft.TextStyle(color=ft.Colors.WHITE),
                            text_style=ft.TextStyle(color=ft.Colors.WHITE),
                            border_color=FG,
                            height=35,
                            border_radius=15,
                            bgcolor=BG,
                            text_size=14,
                            on_change=lambda e: update_search_value(e.control.value)


                            ),
                        expand=True
                    ),
                    ft.IconButton(
                        icon=ft.Icons.SEARCH,
                        icon_color=ft.Colors.WHITE,
                        on_click=handle_search
                        ),
                    ft.IconButton(icon=ft.Icons.MUSIC_NOTE,icon_color=ft.Colors.WHITE),
                ]),
                padding=ft.Padding(20, 40, 20, 20),
            )